package org.deadline.service.user;

import java.util.List;
import org.deadline.model.user.PasswordHistory;
import org.deadline.repository.user.PasswordHistoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class PasswordHistoryServiceImpl implements PasswordHistoryService {

	@Autowired
    PasswordHistoryRepository passwordHistoryRepository;

	public long countAllPasswordHistorys() {
        return passwordHistoryRepository.count();
    }

	public void deletePasswordHistory(PasswordHistory passwordHistory) {
        passwordHistoryRepository.delete(passwordHistory);
    }

	public PasswordHistory findPasswordHistory(Long id) {
        return passwordHistoryRepository.findOne(id);
    }

	public List<PasswordHistory> findAllPasswordHistorys() {
        return passwordHistoryRepository.findAll();
    }

	public List<PasswordHistory> findPasswordHistoryEntries(int firstResult, int maxResults) {
        return passwordHistoryRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void savePasswordHistory(PasswordHistory passwordHistory) {
        passwordHistoryRepository.save(passwordHistory);
    }

	public PasswordHistory updatePasswordHistory(PasswordHistory passwordHistory) {
        return passwordHistoryRepository.save(passwordHistory);
    }
}
